#include <iostream>
#include <algorithm>
using namespace std;

const int N = 2e5 + 1;
using pii = pair<int, int>;
pii arr[N];
int n, a, b, res;

int main() 
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        arr[i].first = a;
        arr[i].second = b;
    }
    sort(arr, arr + n);
    int l = arr[0].first, r = arr[0].second;
    for (int i = 1; i < n; i++)
    {
        int a = arr[i].first, b = arr[i].second;
        if (a >= r) res++;
        else b = min(b, r);
        l = a;
        r = b;
    }
    cout << res + 1 << endl;
    return 0;
}